import 'package:flutter/material.dart';

import 'package:get/get.dart';

import '../controllers/project_list_controller.dart';
import 'package:banquanjie_app/app/widget/common/customScaffold.dart';
import 'package:banquanjie_app/app/services/screenAdapter.dart';
import 'package:banquanjie_app/app/widget/common/dropdownMenu.dart';
import 'package:banquanjie_app/app/widget/project/card.dart';
class ProjectListView extends GetView<ProjectListController> {
  const ProjectListView({super.key});
  
  @override
  Widget build(BuildContext context) {
    return Customscaffold(
      title: '项目投融', 
      child: Obx(() =>Column(
        children: [
          Container(
            width: double.infinity,
            height: ScreenAdapter.width(88),
            decoration: BoxDecoration(
              color: Colors.white,
              border: Border(top: BorderSide(color: Color(0XFFF4F7FC)))
            ),
            child: Row(
              children: [
                Expanded(
                  flex: 1,
                  child: Row(
                    children: [SizedBox(width: ScreenAdapter.width(28)),
                      Container(
                        margin: EdgeInsets.only(right: ScreenAdapter.height(22)),
                        width: ScreenAdapter.width(108),
                        height: ScreenAdapter.width(50),
                        child: ElevatedButton(
                          style: ButtonStyle(
                            padding: WidgetStatePropertyAll(EdgeInsets.all(0)),
                            backgroundColor: WidgetStateProperty.all(controller.tempQuery['sortType'] == 3 ? Color.fromRGBO(0,178,119,1): Color(0xFFF2F2F2)),
                          ),
                          onPressed: (){
                            if (controller.tempQuery['sortType'] == 3) return;
                            controller.setSearchQueryValue('sortType', 3);
                            controller.onSearch();
                          },
                          child: Text('最新', style: TextStyle(color: controller.tempQuery['sortType'] == 3 ? Colors.white:Colors.black, fontSize: ScreenAdapter.fontSize(28)),)
                        )
                      ),
                      Container(
                        margin: EdgeInsets.only(right: ScreenAdapter.height(22)),
                        width: ScreenAdapter.width(108),
                        height: ScreenAdapter.width(50),
                        child: ElevatedButton(
                          style: ButtonStyle(
                            padding: WidgetStatePropertyAll(EdgeInsets.all(0)),
                            backgroundColor: WidgetStateProperty.all(controller.tempQuery['sortType'] == 2? Color.fromRGBO(0,178,119,1): Color(0xFFF2F2F2)),
                          ),
                          onPressed: (){
                            if (controller.tempQuery['sortType'] == 2) return;
                            controller.setSearchQueryValue('sortType', 2);
                            controller.onSearch();
                          },
                          child: Text('推荐', style: TextStyle(color: controller.tempQuery['sortType'] == 2 ? Colors.white : Colors.black, fontSize: ScreenAdapter.fontSize(28)),)
                        )
                      ),
                    ],
                  )
                ),
                
                
                SizedBox(
                  width: ScreenAdapter.width(200),
                  child: DropDownMenu(
                    closeCallBack: () {
                      controller.closeSearchMask();
                    },
                    controller: controller.dropDownMenuController,
                    items: const ['项目筛选'],
                    dropItems: [
                      Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Obx(() => Padding(
                            padding: EdgeInsets.all(ScreenAdapter.width(20)),
                            child: Column(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children: [
                                Text('项目类型', style: TextStyle(height: 3, fontSize: ScreenAdapter.fontSize(28), color: Colors.black)),
                                SizedBox(height: ScreenAdapter.width(12)),
                                Wrap(
                                  runSpacing: ScreenAdapter.width(30),
                                  spacing: ScreenAdapter.width(8),
                                  children: [
                                    for(int i = 0; i < controller.dicList['filmTypeList'].length; i++)
                                      InkWell(
                                        onTap: (){
                                          controller.setSearchQueryValue('filmType', controller.dicList['filmTypeList'][i]['id']);
                                        },
                                        child: Container(
                                          padding: EdgeInsets.symmetric(horizontal: ScreenAdapter.width(8)),
                                          constraints: BoxConstraints(
                                            minWidth: ScreenAdapter.width(170)
                                          ),
                                          height: ScreenAdapter.width(56),
                                          decoration: BoxDecoration(
                                            color: controller.tempQuery['filmType'] == controller.dicList['filmTypeList'][i]['id'] ? Color.fromRGBO(0,178,119,.1) : Color(0xFFF7F7F7),
                                            borderRadius: BorderRadius.circular(ScreenAdapter.width(56))
                                          ),
                                          child: Text(
                                            controller.dicList['filmTypeList'][i]['dicName'], 
                                            textAlign: TextAlign.center, 
                                            style: TextStyle(
                                              height: 2.15, 
                                              fontSize: ScreenAdapter.fontSize(26), 
                                              color: controller.tempQuery['filmType'] == controller.dicList['filmTypeList'][i]['id'] ? Color(0xFF00b277) : Colors.black)
                                            )
                                        )
                                      ),
                                      
                                  ]
                                ),
                                SizedBox(height: ScreenAdapter.width(12)),
                                Text('项目阶段', style: TextStyle(height: 3, fontSize: ScreenAdapter.fontSize(28), color: Colors.black)),
                                SizedBox(height: ScreenAdapter.width(12)),
                                Wrap(
                                  runSpacing: ScreenAdapter.width(30),
                                  spacing: ScreenAdapter.width(8),
                                  children: [
                                    for(int i = 0; i < controller.dicList['progressList'].length; i++)
                                      InkWell(
                                        onTap: (){
                                          controller.setSearchQueryValue('projectPhase', controller.dicList['progressList'][i]['id']);
                                        },
                                        child: Container(
                                          padding: EdgeInsets.symmetric(horizontal: ScreenAdapter.width(8)),
                                          constraints: BoxConstraints(
                                            minWidth: ScreenAdapter.width(170)
                                          ),
                                          height: ScreenAdapter.width(56),
                                          decoration: BoxDecoration(
                                            color: controller.tempQuery['projectPhase'] == controller.dicList['progressList'][i]['id'] ? Color.fromRGBO(0,178,119,.1) : Color(0xFFF7F7F7),
                                            borderRadius: BorderRadius.circular(ScreenAdapter.width(56))
                                          ),
                                          child: Text(
                                            controller.dicList['progressList'][i]['dicName'], 
                                            textAlign: TextAlign.center, 
                                            style: TextStyle(
                                              height: 2.15, 
                                              fontSize: ScreenAdapter.fontSize(26), 
                                              color: controller.tempQuery['projectPhase'] == controller.dicList['progressList'][i]['id'] ? Color(0xff00b277): Colors.black
                                            )
                                          )
                                        )
                                      )
                                      
                                  ]
                                ),
                                Text('是否报审', style: TextStyle(height: 3, fontSize: ScreenAdapter.fontSize(28), color: Colors.black)),
                                SizedBox(height: ScreenAdapter.width(12)),
                                Wrap(
                                  runSpacing: ScreenAdapter.width(30),
                                  spacing: ScreenAdapter.width(8),
                                  children: [
                                    for(int i = 0; i < controller.dicList['auditStatusList'].length; i++)
                                      InkWell(
                                        onTap: (){
                                          controller.setSearchQueryValue('auditStatus', controller.dicList['auditStatusList'][i]['id']);
                                        },
                                        child: Container(
                                          padding: EdgeInsets.symmetric(horizontal: ScreenAdapter.width(8)),
                                          constraints: BoxConstraints(
                                            minWidth: ScreenAdapter.width(170)
                                          ),
                                          height: ScreenAdapter.width(56),
                                          decoration: BoxDecoration(
                                            color: controller.tempQuery['auditStatus'] == controller.dicList['auditStatusList'][i]['id'] ? Color.fromRGBO(0,178,119,.1) : Color(0xFFF7F7F7),
                                            borderRadius: BorderRadius.circular(ScreenAdapter.width(56))
                                          ),
                                          child: Text(
                                            controller.dicList['auditStatusList'][i]['dicName'], 
                                            textAlign: TextAlign.center, 
                                            style: TextStyle(
                                              height: 2.15, 
                                              fontSize: ScreenAdapter.fontSize(26), 
                                              color: controller.tempQuery['auditStatus'] == controller.dicList['auditStatusList'][i]['id'] ? Color(0xff00b277) :Colors.black)
                                            )
                                        )
                                      )
                                  ]
                                ),
                              ],
                            )
                          )),
                          Container(
                            margin: EdgeInsets.only(top: ScreenAdapter.width(10)),
                            padding: EdgeInsets.symmetric(horizontal: ScreenAdapter.width(38)),
                            height: ScreenAdapter.width(146),
                            alignment: Alignment.center,
                            decoration: BoxDecoration(
                              border: Border(top: BorderSide(color: Color(0xfff3f8ff)))
                            ),
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Expanded(
                                  flex: 1,
                                  child: SizedBox(
                                    height: ScreenAdapter.width(80),
                                    child: ElevatedButton(
                                      onPressed: (){
                                        controller.onClearCondition();
                                      }, 
                                      style: ButtonStyle(
                                        padding: WidgetStatePropertyAll(EdgeInsets.all(0)),
                                        shape: WidgetStatePropertyAll(RoundedRectangleBorder(borderRadius: BorderRadius.circular(ScreenAdapter.width(12)))),
                                        backgroundColor: WidgetStateProperty.all(Color(0xffF4F4F4)),
                                      ),
                                      child: Text('清空条件', style: TextStyle(color: Colors.black, fontSize: ScreenAdapter.fontSize(28)))
                                    )
                                  ),
                                ),
                                SizedBox(width: ScreenAdapter.width(20)),
                                Expanded(
                                  flex: 1,
                                  child: SizedBox(
                                  height: ScreenAdapter.width(80),
                                  child: ElevatedButton(
                                    onPressed: (){
                                      controller.onSearch();
                                    }, 
                                    style: ButtonStyle(
                                      padding: WidgetStatePropertyAll(EdgeInsets.all(0)),
                                      shape: WidgetStatePropertyAll(RoundedRectangleBorder(borderRadius: BorderRadius.circular(ScreenAdapter.width(12)))),
                                      backgroundColor: WidgetStateProperty.all(Color(0xff00b277)),
                                    ),
                                    child: Text('确定', style: TextStyle(color: Colors.white, fontSize: ScreenAdapter.fontSize(28)))
                                  )
                                )
                                )
                                
                                
                                
                              ],
                            )
                          )
                            

                          ]
                      ),

                    ],
                    selectedColor: Colors.black,
                  )
                )
                
              ]
            ),
          ),
          
          Expanded(
            flex: 1,
            child: controller.total == 0 ? Center(child: Text('暂无数据')) : RefreshIndicator(
              onRefresh: controller.onRefresh,
              child: ListView.builder(
                padding: EdgeInsets.all(ScreenAdapter.width(20)),
                controller: controller.scrollController,
                itemCount: controller.projectList.length,
                itemBuilder: (context, index) {
                  return Column(
                    children: [
                      Padding(
                        padding: EdgeInsets.only(bottom: ScreenAdapter.width(20)),
                        child: ProjectCard(item: controller.projectList[index])
                      ),
                      if (controller.total.value == controller.projectList.length && index == controller.projectList.length - 1)
                        Text('到底了', style: TextStyle(height: 2,color: Colors.black,fontSize: ScreenAdapter.fontSize(28)),)
                    ],
                  );
                }
              )
            )
          ),
        ],
      )
      )
    );
  }
}
